home *** CD-ROM | disk | FTP | other *** search
- package LockemUp;
-
- import com.siemens.mp.game.ExtendedImage;
- import com.siemens.mp.game.GraphicObjectManager;
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.List;
-
- public class GameScreen extends BaseScreen {
- private static final int GAME_SCREEN_WIDTH = 88;
- private static final int GAME_SCREEN_HEIGHT = 77;
- private static final String MAP_DATA_FILE = "res\\maps.dat";
- private static final String MAP_TILE_FILE = "res\\wall.bin";
- private static final String MAP_TILE_ACTORS = "res\\actors.bin";
- private int mapNumber;
- private int iState;
- private boolean readyToPaint = false;
- private CommandListener listener;
- private boolean repaintBack;
- private Image gameScreenImage;
- private ExtendedImage gameScreen = null;
- private GraphicObjectManager gfxManager;
- private GameBoard back;
-
- public GameScreen(int var1) {
- this.mapNumber = var1;
-
- try {
- this.gameScreenImage = Image.createImage(88, 77);
- this.gameScreen = new ExtendedImage(this.gameScreenImage);
- this.gameScreen.clear((byte)0);
- this.gfxManager = new GraphicObjectManager();
- byte[] var2 = ((BaseScreen)this).ReadByteArray("res\\maps.dat", 4, var1 * 2);
- int var3 = this.byteToInt(var2[0]) * 256 + this.byteToInt(var2[1]);
- int var4 = this.byteToInt(var2[2]) * 256 + this.byteToInt(var2[3]) - var3;
- var2 = ((BaseScreen)this).ReadByteArray("res\\maps.dat", var4, var3);
- byte[] var5 = ((BaseScreen)this).ReadByteArray("res\\wall.bin", 42, 0);
- byte[] var6 = ((BaseScreen)this).ReadByteArray("res\\actors.bin", 496, 0);
- switch (this.mapNumber) {
- case 0:
- case 1:
- this.back = new GameBoard(this.gfxManager, var2, var5, var6, 0);
- break;
- case 2:
- this.back = new GameBoard(this.gfxManager, var2, var5, var6, 1);
- break;
- case 3:
- this.back = new GameBoard(this.gfxManager, var2, var5, var6, 2);
- break;
- default:
- this.back = new GameBoard(this.gfxManager, var2, var5, var6, 3);
- }
- } catch (Exception var7) {
- System.out.println("Exception: " + var7);
- }
-
- this.readyToPaint = true;
- this.iState = 0;
- this.repaintBack = true;
- }
-
- public void reInit() {
- this.iState = 0;
- switch (this.mapNumber) {
- case 0:
- case 1:
- this.back.reInit(0);
- break;
- case 2:
- this.back.reInit(1);
- break;
- case 3:
- this.back.reInit(2);
- break;
- default:
- this.back.reInit(3);
- }
-
- this.readyToPaint = true;
- this.repaintBack = true;
- }
-
- public void setOnSound(boolean var1) {
- this.back.setOnSound(var1);
- }
-
- public void setOnVibrate(boolean var1) {
- this.back.setOnVibrate(var1);
- }
-
- public void Dispose() {
- this.gameScreen = null;
- this.gfxManager = null;
- this.back.Dispose();
- }
-
- public void run() {
- boolean var1 = true;
-
- while(var1) {
- try {
- Thread.sleep(20L);
- } catch (Exception var5) {
- }
-
- int var2 = this.back.manageMoves();
-
- try {
- if (var2 > 0) {
- this.gameScreen.clear((byte)0);
- } else {
- this.gameScreen.setPixels(this.back.getBackground(), 0, 0, 88, 77);
- this.gfxManager.paint(this.gameScreen, 0, 0);
- }
-
- ((Canvas)this).repaint();
- } catch (Exception var4) {
- System.out.println("Exception: " + var4);
- }
-
- if (this.iState != 0 || var2 > 0) {
- if (this.iState == 0) {
- this.iState = var2;
- }
-
- var1 = false;
- }
- }
-
- }
-
- public void setRepaintFlag(boolean var1) {
- this.repaintBack = var1;
- }
-
- public int getReturnValue() {
- return this.iState;
- }
-
- public void setStateValue(int var1) {
- this.iState = var1;
- if (var1 > 0) {
- this.gameScreen.clear((byte)0);
- this.gameScreen.blitToScreen(2, 1);
- this.readyToPaint = false;
- this.repaintBack = false;
- }
-
- }
-
- public void paint(Graphics var1) {
- if (this.repaintBack) {
- var1.drawLine(0, 0, 0, 79);
- var1.drawLine(90, 0, 90, 79);
- Image var2 = Image.createImage(8, 75);
- ExtendedImage var3 = new ExtendedImage(var2);
- var3.clear((byte)-127);
- byte[] var4 = ((BaseScreen)this).ReadByteArray("res\\right.bin", 75, 0);
- var3.setPixels(var4, 0, 0, 8, 75);
- var3.blitToScreen(92, 0);
- this.repaintBack = false;
- }
-
- if (this.gameScreen != null && this.readyToPaint) {
- try {
- this.gameScreen.blitToScreen(2, 1);
- } catch (Exception var5) {
- System.out.println("Exception: " + var5);
- }
- }
-
- }
-
- public void setCommandListener(CommandListener var1) {
- super.setCommandListener(var1);
- this.listener = var1;
- }
-
- protected void keyPressed(int var1) {
- if (var1 == -12) {
- this.listener.commandAction(List.SELECT_COMMAND, this);
- } else {
- this.back.turnArrow(var1 - 48);
- }
- }
-
- protected void keyReleased(int var1) {
- }
-
- protected void keyRepeated(int var1) {
- }
-
- private int byteToInt(byte var1) {
- if (var1 >= 0) {
- return var1;
- } else {
- int var2 = var1 + 256;
- return var2;
- }
- }
- }
-